package com.xxrl.shop.common.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * @author mis
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ItemSimilarity implements Serializable, Comparable<ItemSimilarity> {
    private static final double EPS = 1e-5;

    private int productId1;

    private int productId2;
    private double similar;

    @Override
    public int compareTo(ItemSimilarity o) {
        double dif = similar - o.similar;
        if (Math.abs(dif) < EPS ) {
            return 0;
        }
        return (int) dif;
    }
}
